package demo05.InnerClassThread;
/*
* 匿名内部类方式创建多线程*/
public class Demo01InnerClassThread {
    public static void main(String[] args) {
        new Thread(){
            @Override
            public void run() {
                for (int i = 0; i < 20; i++) {
                    System.out.println(Thread.currentThread().getName() +":"+ i);
                }
            }
        }.start();
        //终极无敌简化版本，两种方法用lambda表达式殊途同归
         new Thread(() -> {
             for (int i = 0; i < 20; i++) {
                 System.out.println(Thread.currentThread().getName() +":"+ i);
             }
         }).start();

        for (int i = 0; i < 20; i++) {
            System.out.println(Thread.currentThread().getName() +":"+ i);
        }
        Runnable r= new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 20; i++) {
                    System.out.println(Thread.currentThread().getName());
                }
            }
        };
        new Thread(r).start();


    }
}
